package designpatterns.collectiontest;

import javafx.concurrent.Task;

import java.util.concurrent.*;

public class Test {
    public static void main(String[] args) {

//        LinkedBlockingDeque<Object> deque = new LinkedBlockingDeque<>();

        LinkedBlockingQueue<String> queue = new LinkedBlockingQueue<>();

        boolean b = queue.add("hello01");
        boolean offer = queue.offer("hello02");

        System.out.println("queue.poll() = " + queue.poll());
        System.out.println("queue.poll() = " + queue.poll());
        System.out.println("queue.poll() = " + queue.poll());
        System.out.println("queue.poll() = " + queue.poll());


        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                10, 20, 1000, TimeUnit.MICROSECONDS, new LinkedBlockingQueue<>(),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.DiscardOldestPolicy()
        );

        ExecutorService service = Executors.newCachedThreadPool();
        service.submit(new Task<String>() {
            @Override
            protected String call() throws Exception {
                return null;
            }
        });
    }
}
